#pragma once

#include "ColligereListCtrl.hpp"
#include "ColligereDatabaseHandlerBase.hpp"

namespace col {

class SyncTypeClientData : public wxClientData
{
public:
	SyncTypeClientData ( wxUint32 syncType ) : mSyncType ( syncType )
	{
		wxASSERT ( mSyncType == DatabaseHandlerBase::SyncType::Off ||
			mSyncType == DatabaseHandlerBase::SyncType::Normal ||
			mSyncType == DatabaseHandlerBase::SyncType::Full );
	}
	wxUint32 GetType() const { return mSyncType; }
private:
	wxUint32 mSyncType;
};

//! A dialog for showing application preferences.
class PreferencesDialog : public wxDialog 
{
public:
	PreferencesDialog ( wxFrame *pParent );
	virtual ~PreferencesDialog();
private:
	/*! @brief Default constructor.
	 *
	 * Only for the DECLARE_DYNAMIC_CLASS macro.
	 **/
	PreferencesDialog() { }

	//! Saves preferences from the dialog controls.
	void SaveControlValues();
	//! Loads preferences from the config handler to the dialog controls.
	void LoadSettings();

	//! Connects all GUI event handlers.
	void ConnectEventHandlers();

	void LoadVarToGenSettingCheckListBox ( wxUint32 varId );

	///////////////////////////////////////////////
	// Event handlers
	///////////////////////////////////////////////

	void OnListBoxItemSelected ( wxCommandEvent &rEvent );
	void OnButtonResetDefaults ( wxCommandEvent &rEvent );
	void OnButtonOk ( wxCommandEvent &rEvent );
	void OnButtonBrowseDefaultDb ( wxCommandEvent &rEvent );
	
	wxCheckListBox *mpGenSettingsCtrl;

	wxCheckBox *mpDbAutoSaveCtrl, *mpDbAutoVacuumCtrl;
	
	wxTextCtrl *mpDefaultDbCtrl;
	wxComboBox *mpDbSyncTypeCtrl, *mpDbCompressionLevelCtrl;

	std::map < wxInt32, wxUint32 > mGenSettingsItemData;

//public:
	DECLARE_DYNAMIC_CLASS ( PreferencesDialog );
};

}